package com.zzzyh.forumsystemclient.cotroller;

import com.zzzyh.forumsystemclient.common.AppResult;
import com.zzzyh.forumsystemclient.model.SysFriend;
import com.zzzyh.forumsystemclient.services.IFriendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/friend")
public class SysFriendController {
    @Autowired
    private IFriendService friendService;
    @RequestMapping("/list")
    public AppResult<List<SysFriend>> list(){
        return AppResult.success(friendService.list());
    }

    @RequestMapping("/apply")
    public AppResult<String> apply(@RequestBody SysFriend sysFriend){
        sysFriend.setStatus(1);
        friendService.apply(sysFriend);
        return AppResult.success("申请成功，请等待管理员审核");
    }
}
